package com.dianrui.agent.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.dianrui.agent.R;
import com.dianrui.agent.fragment.DeviceNoServingFragment;
import com.dianrui.agent.fragment.DeviceOfflineFragment;
import com.dianrui.agent.fragment.DeviceOperationFragment;

public class DeviceListPageAdapter extends FragmentPagerAdapter {
    private String[] mTitles = new String[]{"运营中", "未投放","离线"};
    private Context context;

    public DeviceListPageAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 1) {
            return new DeviceNoServingFragment();
        } else if (position == 2) {
            return new DeviceOfflineFragment();
        }
        return new DeviceOperationFragment();

    }

    public View getTabView(int position) {
        View tabView = LayoutInflater.from(context).inflate(R.layout.tab_item_txt, null);
        TextView textView = tabView.findViewById(R.id.show_tab_title);
        textView.setText(mTitles[position]);
        return tabView;
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
